<?php
class PublicAction extends Action{
	public function login(){
		if(empty($_POST['acount']) || empty($_POST['password'])){
			$errmsg = '<script type="text/javascript">用户名或密码不能为空!</script>';
		}
		if(!empty($errmsg)){
			$this->assign('acount',$_POST['acount']);
			$this->assign('errmsg',$errmsg);
			$this->redirect('Index/index');
			exit();
		}else{
			$Suser = M('Suser');
			$vo=$Suser->join("store on suser.suser_id = store.store_mid")
				->where("suser_id='".$_POST['account']."' and suser_password='".md5($_POST['password'])."'")
				->select();
			if ($vo){
				$suser = new Session();
				$suser->set('account',trim($_POST['account']));
				$suser->set('qq',trim($_POST['suser_qq']));
				$suser->set('pointcard',trim($_POST['suser_pointcard']));
				$suser->set('totlepointcard',trim($_POST['suser_totlepointcard']));
				$suser->set('tel',trim($_POST['suser_tel']));
				$suser->set('store_id',trim($_POST['store_id']));
				$suser->set('type',trim($_POST['store_type']));
				$suser->set('address',trim($_POST['store_address']));
				$suser->set('name',trim($_POST['store_name']));
				$suser->set('category',trim($_POST['store_category']));
				$this->redirect('UserAdmin/index');
			}else{
				$errmsg = '<script type="text/javascript">账号或者密码错误！</script>';
				$this->assign('account',$_POST['account']);
				$this->assign('errmsg',$errmsg);
				$this->display('login');
			} 
		}
	}
	
	public function logout(){
		unset($_SESSION);
		session_destroy();
		$this->redirect("Index/index");
	}
}
?>